package com.iretailer.report.model;

import com.alibaba.fastjson.annotation.JSONField;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.iretailer.report.util.TimeUtil;
import lombok.Data;

import java.text.MessageFormat;
import java.time.LocalDate;

/**
 * @Auther Bennie
 * @Date 2020/6/9 15:09
 * @Description
 */
@Data
@TableName(value = "t_weathers")
public class Weathers {

    @JSONField(name = "Id")
    @TableId(value = "Id", type = IdType.UUID)
    private String id;

    @JSONField(name = "CityId")
    @TableField(value = "CityId")
    private String cityId;

    @JSONField(name = "CityName")
    @TableField(value = "CityName")
    private String cityName;

    @JSONField(name = "Date")
    @TableField(value = "Date")
    private LocalDate date = LocalDate.now();

    @JSONField(name = "HighTemp")
    @TableField(value = "HighTemp")
    private Double highTemp;

    @JSONField(name = "LowTemp")
    @TableField(value = "LowTemp")
    private Double lowTemp;

    @JSONField(name = "TempUnit")
    @TableField(value = "TempUnit")
    private String tempUnit;

    @JSONField(name = "PM25")
    @TableField(value = "PM25")
    private Double pm25;

    @JSONField(name = "Wind")
    @TableField(value = "Wind")
    private String wind;

    @JSONField(name = "WindDir")
    @TableField(value = "WindDir")
    private String windDir;


    @JSONField(name = "WindSc")
    @TableField(value = "WindSc")
    private String windSc;


    @JSONField(name = "WindDeg")
    @TableField(value = "WindDeg")
    private Integer windDeg;


    @JSONField(name = "WindSpd")
    @TableField(value = "WindSpd")
    private Integer windSpd;


    @JSONField(name = "WeatherName")
    @TableField(value = "WeatherName")
    private String weatherName;

    @TableField(value = "dayPictureUrl")
    private String dayPictureUrl;

    @TableField(value = "nightPictureUrl")
    private String nightPictureUrl;

    public String getCityId_date() {
        if (cityId != null && date != null) {
            return MessageFormat.format("{0}_{1}", this.cityId, TimeUtil.localDate_format(this.date));
        } else {
            return "";
        }
    }
}
